using System;
using System.Collections.Generic;
using NHibernate;
using System.Linq;

namespace Web.Model
{
    public class CommentBase : Entity
    {
        public User Author { get; set; }

        public string Text { get; set; }

        public DateTime DateCreated { get; set; }

        public IList<User> Likes { get; set; }
    }

    public class Comment : CommentBase
    {
        public HeadComment HeadComment { get; set; }
    }

    public class HeadComment : CommentBase
    {
        public Entity Story { get; set; }

        public IList<Comment> ChildComments { get; set; }

        public void Clear(ISession session)
        {
            ChildComments.ToList().ForEach(c => session.Delete(c));
            ChildComments.Clear();
        }
    }
}